<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.educationsystem.utils.CookieEncryptTool"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-Hans-CN" class="fullscreen-bg">
<script type="text/javascript">
function reloadImage(t){
   t.src="./ImageServlet?flag="+Math.random();
}
function changeImage()
{
document.getElementById("image").src="./ImageServlet?flag="+Math.random();
}
setInterval("changeImage();", 110000);
</script>
	<style>
		.fx {
			position: relative;
		}
		.zj {
			/*float: left;*/
			position: absolute;
			top: 7px;
			left: 130px;
		}
		.zj2 {
			/*float: left;*/
			position: absolute;
			top: 114px;
			left: 0px;
		}
	</style>
<head>
	<title>Login</title>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<!-- VENDOR CSS -->
	<link rel="stylesheet" href="assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="assets/vendor/linearicons/style.css">
	<!-- MAIN CSS -->
	<link rel="stylesheet" href="assets/css/main.css">
	<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
	<link rel="stylesheet" href="assets/css/demo.css">
	<!-- GOOGLE FONTS -->
	<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet">
	<!-- ICONS -->
	<link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="assets/img/favicon.png">
</head>

<body>
<%
	String applicantUsername = "";
	String applicantPassword = "";
	String applicantSF = "";
	boolean havacookie=false;
	
	//从客户端获取Cookie
	Cookie[] cookies = request.getCookies();
	if(cookies != null){
		for(Cookie cookie : cookies){
			if("COOKIE_APPLICANTUSERNMAE".equals(cookie.getName())){
				applicantUsername = CookieEncryptTool.decodeBase64(cookie.getValue());
				havacookie=true;
			}
			if("COOKIE_APPLICANTPASSWORD".equals(cookie.getName())){
				applicantPassword = CookieEncryptTool.decodeBase64(cookie.getValue());
				havacookie=true;
			}
			if("COOKIE_APPLICANTSF".equals(cookie.getName())){
				applicantSF = CookieEncryptTool.decodeBase64(cookie.getValue());
				havacookie=true;
			}
		}
	}
%>
	<!-- WRAPPER -->
	<div id="wrapper">
		<div class="vertical-align-wrap">
			<div class="vertical-align-middle">
				<div class="auth-box ">
					<div class="left">
						<div class="content">
							<div class="header">
								<div class="logo text-center"><img src="assets/img/logo-dark.png" alt="Klorofil Logo"></div>
								<p class="lead">登录到您的帐户</p>
							</div>
							<!-- form是一个表单 用于提交数据   action表示当前数据提交到那个请求路径   -->
							<form class="form-auth-small" action="/bysjxt/Login" method="post">
								<div class="form-group">
									<label for="signin-email" class="control-label sr-only">Name</label>
									<input type="text" class="form-control" id="signin-email" value="<%= applicantUsername%>"
									required name="login_name" placeholder="请输入用户名">
								</div>
								<div class="form-group">
									<label for="signin-password" class="control-label sr-only">Password</label>
									<input type="password" class="form-control" id="signin-password" value="<%= applicantPassword%>"
									required name="password" placeholder="请输入密码">
								</div>
								<div class="form-group fx" style="float:left">
									<input type="text"style="float:left" class="form-control" required id="signin-email" maxlength=4 size="10" 
									placeholder="请输入验证码" onkeyup="value=value.replace(/[^\d]/g,'')" name="checkcode">
                        			<img id="image" class="zj" src="./ImageServlet" alt="看不清，请点击这里！" onclick="reloadImage(this)" >
								</div>
								<div style="float:right">
									<select name="sf" >
									<%
									if(havacookie) {
										if(applicantSF.equals("admin")){
									%>
									  <option value ="admin">管理员</option>
									  <option value ="student">学生</option>
									  <option value="teacher">教师</option>
									<% }else if(applicantSF.equals("student")){
									%>
									  <option value ="student">学生</option>		  
									  <option value="teacher">教师</option>
									  <option value ="admin">管理员</option>
									<%
									}else if(applicantSF.equals("teacher")){
									%>
									  <option value="teacher">教师</option>
									  <option value ="student">学生</option>
									  <option value ="admin">管理员</option>
									<% }else{ havacookie=false;%>
									  <option value ="admin">管理员</option>
									  <option value ="student">学生</option>
									  <option value="teacher">教师</option>
									<%}}else{%>
									  <option value ="admin">管理员</option>
									  <option value ="student">学生</option>
									  <option value="teacher">教师</option>
									<% }%>
									</select>
								</div>
								<div style=”clear:both”></div>
								<div class="fx">
									<label class="zj2">
									<%
									if(havacookie) {
									%>
										<input type="checkbox" checked="checked" name="rememberMe" id="rememberMe" value="true">
										<span>记住密码</span>
									<% }else {
									%>
										<input type="checkbox" name="rememberMe" id="rememberMe" value="true">
										<span>记住密码</span>
									<%
									}
									%>
									</label>
								</div>
								<button type="submit" class="btn btn-primary btn-lg btn-block">登录</button>
								<div class="bottom">
									<span class="helper-text"><i class="fa fa-lock"></i> <a href="#" onClick="return confirm('请联系管理员重置密码！');">忘记密码?</a></span>
								</div>
								<br>
								<font style="color: red;">${message}</font>
							</form>
						</div>
					</div>
					<div class="right">
						<div class="overlay"></div>
						<div class="content text">
							<h1 class="heading">欢迎来到毕业设计选题系统</h1>
							<p>广东外语外贸大学南国商学院</p>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
		</div>
	</div>
	<!-- END WRAPPER -->
	<div class="clearfix"></div>
	<footer>
		<div class="container-fluid">
			<p class="copyright">
				Copyright &copy; 2020.GWNG.<a href="https://www-new.gwng.edu.cn/" target="_blank"
					title="广外南国">广外南国</a> - Made by <a
					href="https://www.baidu.com/" title="陆学嘉" target="_blank">陆学嘉</a>
			</p>
		</div>
		</footer>
</body>

</html>
